package com.acquisition.task.util;

import com.licheedev.modbus4android.ModbusWorker;

/**
 * modbus管理类
 *
 * @author wuqiwei
 * @date 2021/02/24
 */
public class ModbusUtils extends ModbusWorker {

    private static volatile ModbusUtils sInstance;

    public static ModbusUtils get() {
        ModbusUtils manager = sInstance;
        if (manager == null) {
            synchronized (ModbusUtils.class) {
                manager = sInstance;
                if (manager == null) {
                    manager = new ModbusUtils();
                    sInstance = manager;
                }
            }
        }
        return manager;
    }

    private ModbusUtils() {

    }

    /**
     * 释放整个ModbusManager，单例会被置null
     */
    @Override
    public synchronized void release() {
        super.release();
        sInstance = null;
    }

}
